package com.pk.platform.business.common.web;

import java.util.ArrayList;
import java.util.List;

import com.pk.platform.business.common.service.IContactService;
import com.pk.platform.business.common.vo.ContactVO;
import com.pk.platform.business.core.web.GenericAction;
import com.pk.platform.domain.common.Contact;
import com.pk.platform.domain.common.Kindergarten;
import com.pk.platform.util.SelectOption;
import com.pk.platform.util.WebUtil;
import com.pk.platform.util.constant.Constant;

public class ContactAction extends GenericAction {

	private IContactService contactService;
	
	private Contact ct = new Contact();
	
	private ContactVO ctvo = new ContactVO();

	private List<SelectOption> typeList = new ArrayList<SelectOption>();
	
	private int iskg=0;
	
	public String getContactPage()
	{
		if(iskg==1)
			ctvo.setKindergartenId(kindergartenId);
		lp = contactService.queryContact(ctvo, pager);
		return SUCCESS;
	}
	public String toAddContact()
	{
		return SUCCESS;
	}
	
	public String addContact()
	{
		if(iskg==1){
			Kindergarten k = new Kindergarten(kindergartenId);
			ct.setKindergarten(k);
		}
		message = contactService.addContact(ct);
		return SUCCESS;
	}
	
	public String toUpdateContact()
	{
		ct = contactService.getContactById(ct.getId());
		return SUCCESS;
	}
	
	public String updateContact()
	{
		if(iskg==1){
			Kindergarten k = new Kindergarten(kindergartenId);
			ct.setKindergarten(k);
		}
		contactService.updateContact(ct);
		return SUCCESS;
	}
	
	public String delContact()
	{
		contactService.delContact(ct.getId());
		return SUCCESS;
	}
	
	public IContactService getContactService() {
		return contactService;
	}

	public void setContactService(IContactService contactService) {
		this.contactService = contactService;
	}

	public Contact getCt() {
		return ct;
	}

	public void setCt(Contact ct) {
		this.ct = ct;
	}

	public ContactVO getCtvo() {
		return ctvo;
	}

	public void setCtvo(ContactVO ctvo) {
		this.ctvo = ctvo;
	}

	public List<SelectOption> getTypeList() {
		return WebUtil.constructOptions(Constant.CONTACT_TYPE);
	}

	public void setTypeList(List<SelectOption> typeList) {
		this.typeList = typeList;
	}
	public int getIskg() {
		return iskg;
	}
	public void setIskg(int iskg) {
		this.iskg = iskg;
	}
	
	
}
